package com.touna.regex;

import java.util.regex.Pattern;

/**
 * author: xl
 * time: 2018/6/19 11:55
 * description:正则表达式
 **/
public class RegexTest {

    public static void main(String[] args) {

        String pattern = "[A-z]";
        //邮箱验证
        pattern = "\\w+@.*\\.com$";
        System.out.println(Pattern.matches(pattern, "daxiaoli123@qq.com"));//测试"."匹配任意字符与空白字符"\s与非空白字符\S"

        /**
         *  验证手机号
         * ^以 什么什么开头 [^a]非a
         * (15[^4,\D])排查数字4 其他数字可以
         */
        pattern = "^1[3578]\\d{9}$";
        pattern = "^((17[0-9])|(14[0-9])|(13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$";
        System.out.println(Pattern.matches(pattern, "13412457895"));
        System.out.println(Pattern.matches(pattern, "15746789120"));

        //身份证验证
        pattern = "\\d{17}(X|x|\\*|\\d)";
        System.out.println(Pattern.matches(pattern, "431122198711267619"));
        System.out.println(Pattern.matches(pattern, "43112219871126761x"));


    }



}
